package com.example.demo.task;

public class TestTask {
    public static void main(String[] args) {
        int[] nums = {2,6,4,1,10};
        Integer max = getMax(nums);
        System.out.println(max);

    }

    public static Integer getMax(int[] nums){
        int temp = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums.length-1 < i+2){
                continue;
            }
            temp = Math.max(temp,nums[i] + nums[i + 2]);
        }
        return temp;
    }
}